Skip to content

fix(scan): preserve tracked files without exposing ignored files - #320

Open
mldangelo-oai wants to merge 28 commits into
mainfrom
mdangelo/codex/respect-scan-inventory-gitignore-20260808
Open

fix(scan): preserve tracked files without exposing ignored files#320
mldangelo-oai wants to merge 28 commits into
mainfrom
mdangelo/codex/respect-scan-inventory-gitignore-20260808

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve tracked source files and explicitly selected ignored files while keeping ignored directory descendants out of Git, snapshot, and nested-repository inventories.
  • Apply each filesystem-identified Git worktree's own case and ignore policies while preserving scoped case-renamed tracked files and bounded exact metadata exclusions.
  • Normalize scoped paths, reject user-selected links before SDK canonicalization, and distinguish stale nested metadata from real Git failures.
  • Remove arbitrary timeouts for local Git and ripgrep commands.

Verification

  • bun test tests-ts/scan-inventory.test.ts tests-ts/targets.test.ts (27 passed).
  • Full SDK suite: 996 passed, 11 skipped, 0 failed.
  • Relevant runtime inventory regression, SDK type check, and formatting check.

@github-actions github-actions Bot added the bug Something isn't working label Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45f56e891a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/tests-ts/scan-inventory.test.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 45f56e891a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
@mldangelo-oai mldangelo-oai changed the title fix(scan): keep ignored files out of security inventories fix(scan): preserve tracked files without exposing ignored files Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b6677984b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: b6677984b7

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 540bbd4802

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 540bbd4802

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated

Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 52b82f9444

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 52b82f9444

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb7c5ce615

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: bb7c5ce615

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1baf11d67c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1baf11d67c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@mldangelo-oai
mldangelo-oai marked this pull request as ready for review August 8, 2026 07:17

Copy link
Copy Markdown
Collaborator Author

@codex review

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head bf59601. Verify stale root Git markers safely fall back to snapshots without exposing .git metadata, while preserving nested worktree identity, ignore rules, Windows junction rejection, and tracked-file recovery.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf59601b39

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head c6724ee. Verify malformed and stale Git markers fall back safely, all case variants of Git metadata stay excluded, and Windows junction, ignore-file, nested-worktree, and tracked-file protections remain intact.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6724ee3f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head cf67b34. Verify explicit Git metadata rejection, malformed nested markers, regular ignore files, pruned Windows junctions, case-distinct nested worktrees, tracked paths, and canonical scope boundaries.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: cf67b342b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: cf67b342b1

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head 498b40f. Focus on case-sensitive Git metadata exclusions, ordinary snapshot source directories, Windows metadata aliases, and ignored tracked files.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 498b40f771

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head 2105068. Verify exact Git-metadata alias handling, case-only tracked renames, preserved ignored-file protections, and the focused filesystem regression.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2105068a72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head fb058c6. Verify explicit file and directory case renames, ASCII Git-compatible case matching, multiple visible variants, and pruning of verified Git-metadata aliases.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb058c6ffb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head 3e7917a. Verify root-owned tracked-file recovery through case-renamed ignored directories, per-worktree Git casing, independently scoped repositories, and bounded metadata-ignore files.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e7917a842

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py
Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 3e7917a842

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/_bundled_plugin/scripts/generate_in_scope_files.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the exact current head 708ded5. Verify filesystem-identity-keyed worktrees, fallback after dead-end exact ancestors, actual scoped path spelling, and scope filtering before tracked recovery; local Git calls intentionally remain unbounded under AGENTS.md.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 708ded5d89

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 708ded5d89

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@zcrab-oai zcrab-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated review findings are attached inline after three independent reviews and a separate source-level verification.

"""Atomically write the exact ripgrep inventory sorted as ``LC_ALL=C``."""
command = ["rg", "--files", "--hidden", "--no-ignore", "--glob", "!.git/**", "--", scope]
with tempfile.TemporaryFile(mode="w+b") as inventory:
"""Atomically inventory visible files and ignored files tracked by Git."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Bump the bundled plugin version so Deep Scan receives the inventory fix

This PR changes the packaged inventory helper but does not increase either the bundled plugin manifest or BUNDLED_PLUGIN_VERSION; its merge base and head both retain 0.1.15. bootstrapPlugin() reuses a same-version cached plugin, and the installed Deep Scan MCP server resolves generate_in_scope_files.py from its own installed PLUGIN_ROOT. Existing installations can therefore continue running the old helper with rg --no-ignore, exposing precisely the ignored files this change is meant to protect. Increment the bundled plugin version and synchronized SDK constant.

continue
yield candidate

for root_identity, (root, tracked_paths) in cached_by_root.items():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Do not recover tracked files from nested checkouts ignored by the outer repository

The unrestricted prewalk discovers every embedded Git worktree, including worktrees inside a directory ignored by the outer repository. Their tracked files are then appended here even when the outer repository neither tracks the nested worktree nor explicitly selects it. Thus an ignored private checkout or dependency directory becomes part of a root-scope inventory despite the PR's promise to exclude ignored directory descendants. The existing ignored-nested test force-adds the nested worktree to the outer index, so it does not cover the untracked ignored case. Require the nested root to be visible, outer-tracked, or explicitly selected before recovering its contents.

)
key = normalized(relative_path)
if key not in recorded:
rows.add(relative_path + b"\n")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Reject line-separator characters before writing Git paths to the inventory

Git returns tracked paths as NUL-delimited records, but this recovery path copies their raw bytes into a newline-delimited inventory without rejecting embedded newlines. normalize_candidates.read_scope() later splits the file on newline and validates the resulting records independently, so a single Git-valid pathname can introduce additional existing repository files, including ignored files, into the authorized scope. Reject line separators before serializing recovered paths or use an unambiguous record encoding consistently across producer and consumer.

for ancestor in ancestors:
reject_symbolic_ignore(ancestor)
if selected.is_dir():
for directory, children, files in os.walk(selected, followlinks=False):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Avoid traversing and validating already-ignored directory trees

This os.walk() traverses the entire selected tree before Git or ripgrep ignore rules are applied, pruning only metadata and symbolic-link directories. It therefore visits every ignored dependency/build subtree and calls reject_symbolic_ignore() inside it. A symbolic or nonregular ignore file in an entirely excluded directory can abort an otherwise valid scan, while large ignored trees incur a full unnecessary traversal. Prune excluded directories unless they contain an outer-tracked or explicitly selected path.

for entry in entries:
if not git_metadata_path(parent, entry.name):
grouped.setdefault(
os.fsencode(entry.name).lower(), []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Use Unicode-aware matching when recovering case-renamed tracked files

The case-insensitive recovery groups filesystem names with os.fsencode(name).lower() and performs the same byte-level lowercasing for lookups and selected components. bytes.lower() only handles ASCII, so non-ASCII uppercase/lowercase variants do not match on Windows or case-insensitive macOS filesystems even when core.ignoreCase=true; the tracked source is silently omitted. The new regression test covers only ASCII names. Compare decoded filenames with an appropriate Unicode-aware filesystem case-folding strategy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants